﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:Converters="clr-namespace:Cradiator.Converters"
    xmlns:vm="clr-namespace:Cradiator.ViewModels"
	x:Class="Cradiator.Views.SettingsWindow"
	Title="Settings" 
	WindowStyle="ThreeDBorderWindow"
	SizeToContent="WidthAndHeight" 
	WindowStartupLocation="CenterOwner"
	AllowsTransparency="False"    
	ShowInTaskbar="False" 
	Topmost="False"
	Icon="../Images/Cradiator.ico" 
	ResizeMode="CanResize" Width="500">

    <!-- 
    using a MVVM approach here, so you can populate the properties, and see the effects directly in the designer,
    sometimes a compile is needed to see the effects, but no run is needed anymore.
    -->
    <!--<Window.DataContext>
        <vm:DesignerConfigSettingViewModel 
            CategoryRegEx=".*" 
            URL="http://ccnetlive.thoughtworks.com/ccnet/" 
            PlaySounds="True" 
            PlaySpeech="True" 
            />
    </Window.DataContext>-->

    <Window.Resources>
        <Converters:SecondsToTimeConverter x:Key="TimeConverter" />
        <BooleanToVisibilityConverter x:Key="VisibilityOfBool" />

        <Style x:Key="HeadingLabel" TargetType="{x:Type Label}">
            <Setter Property="FontSize" Value="16" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1">
                        <GradientStop Offset="0" Color="Gray"/>
                        <GradientStop Offset="1" Color="Black"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="FontWeight" Value="Bold" />
            <Setter Property="FontFamily" Value="Segoe, Verdana" />
            <Setter Property="Height" Value="Auto" />
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Padding" Value="0,0,0,0" />
        </Style>

        <Style x:Key="UrlTextStyle" TargetType="{x:Type TextBox}">
            <Setter Property="FontFamily" Value="Tahoma" />
            <Setter Property="FontSize" Value="14" />
        </Style>

        <Style TargetType="{x:Type Label}">
            <Setter Property="Foreground" Value="Gray" />
            <Setter Property="Margin" Value="2" />
        </Style>

        <Style TargetType="{x:Type Button}">
            <Setter Property="Width" Value="70" />
        </Style>

        <Style TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                        <Border x:Name="Border" BorderBrush="Transparent" BorderThickness="7" Margin="5,5,5,5" CornerRadius="3,3,3,3">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
											  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="BorderBrush" TargetName="Border" Value="#efcf7f"/>
                                <Setter Property="BorderThickness" TargetName="Border" Value="7"/>
                                <Setter Property="RenderTransform" >
                                    <Setter.Value>
                                        <ScaleTransform ScaleX="1.1" ScaleY="1.1"/>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="RenderTransformOrigin" Value=".5,.5"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>


    <Border Padding="4" BorderBrush="Black" BorderThickness="5">
        <Grid x:Name="TheGrid">
            <Grid.Resources>
                <Style TargetType="TextBlock">
                    <Setter Property="Margin" Value="0,2,0,2"/>
                    <Setter Property="Height" Value="25"/>
                </Style>
                <Style TargetType="Label">
                    <Setter Property="Height" Value="25"/>
                    <Setter Property="Padding" Value="2"/>
                    <Setter Property="Margin" Value="8,2,8,2"/>
                </Style>
                <Style TargetType="CheckBox">
                    <Setter Property="Height" Value="25"/>
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Label Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" 
				   Margin="0,0,0,10" Padding="5"
				   Style="{StaticResource HeadingLabel}"
				   Content="Cradiator Settings"  />

            <Label Grid.Column="0" Grid.Row="1" Content="URL"/>
            <TextBox Name="urlTextBox" IsReadOnly="{Binding IsMultiView}"
					 Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="1" 
					 TabIndex="0"
					 Style="{StaticResource UrlTextStyle}" 
					 Text="{Binding URL}">
            </TextBox>

            <Expander Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="30" IsExpanded="False" Header="Filters" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Label Grid.Row="0" Grid.Column="0"  Content="Project RegEx"/>
                    <TextBox Grid.Row="0" Grid.Column="1"  Text="{Binding ProjectNameRegEx}" IsReadOnly="{Binding IsMultiView}" Style="{StaticResource UrlTextStyle}" />

                    <Label Grid.Row="1" Grid.Column="0"  Content="Category RegEx"/>
                    <TextBox Grid.Row="1" Grid.Column="1"  Text="{Binding CategoryRegEx}" IsReadOnly="{Binding IsMultiView}" Style="{StaticResource UrlTextStyle}" />

                    <Label Grid.Row="2" Grid.Column="0"  Content="Server RegEx"/>
                    <TextBox Grid.Row="2" Grid.Column="1"  Text="{Binding ServerNameRegEx}" IsReadOnly="{Binding IsMultiView}" Style="{StaticResource UrlTextStyle}" />

                </Grid>
            </Expander>

            <Label Grid.Column="0" Grid.Row="3" Content="Poll Interval" />
            <Label Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="3" 
				   Foreground="CornflowerBlue" Margin="0,2,0,0"
				   Content="{Binding ElementName=pollIntervalSlider, Path=Value, Converter={StaticResource TimeConverter}}">
            </Label>

            <Slider Name="pollIntervalSlider" 
					Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="3" 
					Height="25" Margin="0,0,0,5"
					AutoToolTipPlacement="None"	Minimum="15" Maximum="600" SmallChange="5" LargeChange="30" 
					TabIndex="1" OverridesDefaultStyle="False" 
					Value="{Binding PollFrequency}">
            </Slider>

            <CheckBox Name="showCountdownCheckBox" 
					  Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="3" 
					  Content="Show countdown to next refresh" 
					  IsChecked="{Binding ShowCountdown}">
            </CheckBox>

            <CheckBox Name="playSoundsCheckBox" 
					  Grid.Column="1" Grid.Row="6" 
					  Content="Play Sounds" 
					  IsChecked="{Binding PlaySounds}">
            </CheckBox>

            <Label Grid.Column="2" Grid.Row="6" Content="Broken" HorizontalAlignment="Right"/>
            <TextBox Name="brokenBuildSound" 
					 Grid.Column="3" Grid.ColumnSpan="1" Grid.Row="6" 
					 Style="{StaticResource UrlTextStyle}"
					 Text="{Binding BrokenBuildSound}">
            </TextBox>

            <Label Grid.Column="2" Grid.Row="7" Content="Fixed" HorizontalAlignment="Right"/>
            <TextBox Name="fixedBuildSound" 
					 Grid.Column="3" Grid.ColumnSpan="1" Grid.Row="7" 
					 Style="{StaticResource UrlTextStyle}"
					 Text="{Binding FixedBuildSound}">
            </TextBox>

            <Label Grid.Column="0" Grid.Row="8" Content="" />
            <CheckBox Name="playSpeechCheckBox" 
					  Grid.Column="1" Grid.Row="9" 
					  Content="Play Speech"
					  IsChecked="{Binding PlaySpeech}">
            </CheckBox>

            <Label Grid.Column="2" Grid.Row="9" Content="Broken 'Project..." HorizontalAlignment="Right" />
            <TextBox Name="brokenBuildText" 
					 Grid.Column="3" Grid.ColumnSpan="1" Grid.Row="9" 
					 Style="{StaticResource UrlTextStyle}"
					 Text="{Binding BrokenBuildText}">
            </TextBox>

            <Label Grid.Column="2" Grid.Row="10" Content="Fixed 'Project..." HorizontalAlignment="Right"/>
            <TextBox Name="fixedBuildText" 
					 Grid.Column="3" Grid.ColumnSpan="1" Grid.Row="10" 
					 Style="{StaticResource UrlTextStyle}"
					 Text="{Binding FixedBuildText}">
            </TextBox>
            <Label Grid.Column="2" Grid.Row="11" Content="Voice Name" HorizontalAlignment="Right"/>

            <ComboBox Name="comboInstalledVoices" 
					  Grid.Column="3" Grid.Row="11" 
					  FontFamily="Tahoma" FontSize="14" Height="25"
					  SelectedValuePath="Name"
					  SelectedValue="{Binding Path=SpeechVoiceName, Converter={Converters:InstalledVoiceConverter}}">
            </ComboBox>

            <Label Grid.Column="0" Grid.Row="13" Content="Skin"/>
            <ListBox Name="skinListBox" IsEnabled="{Binding IsOneView}"
					 Grid.Column="1" Grid.Row="13" Grid.ColumnSpan="3" Margin="2" Padding="0"
					 BorderThickness="0" 
					 SelectedValuePath="Tag" 
					 SelectedValue="{Binding SkinName}">

                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>

                <ListBoxItem Tag="Stack" >
                    <Image Source="/Images/StackedIcon.png" ToolTip="Stack"/>
                </ListBoxItem>

                <ListBoxItem Tag="Grid">
                    <Image Source="/Images/GridIcon.png" ToolTip="Grid" />
                </ListBoxItem>

                <ListBoxItem Tag="StackPhoto">
                    <Image Source="/Images/StackedPhotoIcon.png" ToolTip="Stack Photo"/>
                </ListBoxItem>

            </ListBox>

            <Label Grid.Column="0" Grid.Row="14" Grid.ColumnSpan="3" 
				   Content="MultiViews are configured - URL/Filters/Skin are readonly" 
				   Visibility="{Binding Path=IsMultiView, Converter={StaticResource VisibilityOfBool}}"/>

            <StackPanel Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="15" 
						HorizontalAlignment="Right"  Orientation="Horizontal" Margin="3,4">
                <Button Click="Save_Click" IsDefault="True" Margin="0,0,10,0" Content="Save"/>
                <Button Click="Cancel_Click" Grid.Column="1" HorizontalAlignment="Right" Content="Cancel"/>
            </StackPanel>
        </Grid>
    </Border>
</Window>
